#!/bin/sh
echo "hello $LOGNAME, it's nice talking to you"
echo "your present working directory is `pwd`."
echo "you are working on a machine called `uname -n`."
echo "here is a list of your files."
ls
echo "Byte, the time is `date +%T`!"

echo "this script is called $0"
echo "$0  $1 and $2"
echo "The number of positional parameters is $#"


echo 
echo "chapter 2"
name="Zhang Kang"		#local variable(no blank before or after '=') ??????????
export NAME=kangkang		#global variable

echo $name, "$name"
echo '$name'			#do not expand 
echo $NAME


#[ $name = "Zhang Kang" ]	#error ??????????
[ $NAME = "kangkang" ]		#space must exist beside the =
echo $?


echo "Are you ok (y/n) ?"
# read answer
# if [ "$answer" = Y -o "$answer" = y ]
# then
#     echo "Glad to hear it."
# else
#     echo "sorry"
# fi


########## file test ##########
#file=./greetings
#file="~/tmp/t.c"			# ~ is error
file="/home/sk/tmp/t.c"

if [ -d $file ]
then
	echo "$file is a directory"
elif [ -f $file ]
then
	echo "$file exist & is a file"
else
	echo "$file is neither a file nor a directory!"
fi


########## arithmetic ##########
# declare -i				#only valid in cmd line, not supported in script
# num=hello
# echo $num
# num=5+5
# echo $num

# i=5
# echo $i
# let i=i+1
# echo $i

